package com.xywy.beautyand.fragment;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.xywy.beautyand.MyApplication;
import com.xywy.beautyand.R;
import com.xywy.beautyand.ACT.MyCollectionFramAct;
import com.xywy.beautyand.ACT.MySeekFrameAct;
import com.xywy.beautyand.ACT.PersonDataAct;
import com.xywy.beautyand.ACT.SetAboutSugarDoctorFeedBackActivity;
import com.xywy.beautyand.ACT.SetNewPasswordAct;
import com.xywy.beautyand.base.BaseFragment;

/**
 * *****************************************
 * 
 * @Title: PersonalFragment.java
 * @Package com.xywy.performgirlsandroid.fragment
 * @Description: TODO(个人中心)
 * @author smz
 * @date 2014-12-30 10:53:12
 * @version V1.0
 ******************************************* 
 */
public class PersionFragment extends BaseFragment {
	private LinearLayout feedback_lin;
	private TextView logout;
	private LinearLayout ll_myself_info;
	private TextView my_collection;
	private TextView my_seek;
	private LinearLayout ll_collect_mine;

	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.fragment_personal, null);
		initView(view);
		initListener();
		initdata();
		return view;

	}

	private void initView(View view) {
//		RelativeLayout left_img = (RelativeLayout) view
//				.findViewById(R.id.left_img);
//		left_img.setVisibility(View.INVISIBLE);
//		TextView middle_title = (TextView) view.findViewById(R.id.middle_title);
//		middle_title.setText("个人中心");
		feedback_lin = (LinearLayout) view.findViewById(R.id.feedback_lin);
		logout = (TextView) view.findViewById(R.id.logout);

		ll_myself_info = (LinearLayout) view.findViewById(R.id.ll_myself_info);
		my_collection = (TextView) view.findViewById(R.id.my_collection);

		my_seek = (TextView)view.findViewById(R.id.my_seek);
		ll_collect_mine = (LinearLayout) view.findViewById(R.id.ll_collect_mine);
	}

	private void initListener() {
		feedback_lin.setOnClickListener(this);
		logout.setOnClickListener(this);
		ll_myself_info.setOnClickListener(this);

		my_collection.setOnClickListener(this);
		my_seek.setOnClickListener(this);
		ll_collect_mine.setOnClickListener(this);
	}

	private void initdata() {

	}

	@Override
	public void onClick(View v) {
		super.onClick(v);
		switch (v.getId()) {
		case R.id.feedback_lin:
			Intent intent = new Intent(getActivity(),
					SetAboutSugarDoctorFeedBackActivity.class);
			getActivity().startActivity(intent);
			break;
		case R.id.logout:
			createDialog();
			break;
		case R.id.ll_myself_info:
			//MyselfInfoAct
			Intent  intent2=new Intent(getActivity(), PersonDataAct.class);
			startActivity(intent2);
			break;
		case R.id.my_seek:
			Intent intent3 = new Intent(getActivity(), MySeekFrameAct.class);
			startActivity(intent3);
			break;
		case R.id.my_collection:
			Intent intent4 = new Intent(getActivity(),
					MyCollectionFramAct.class);
			startActivity(intent4);
			break;
		case R.id.ll_collect_mine:
			Intent  intent5=new Intent(getActivity(), SetNewPasswordAct.class);
			startActivity(intent5);
			break;
		default:
			break;
		}
	}

	/**
	 * 确定退出
	 */
	private void createDialog() {
		Dialog dialog = new AlertDialog.Builder(getActivity()).setTitle("温馨提示")
				.setMessage("你确定要退出吗")
				.setPositiveButton("确定", new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {
						MyApplication.getInstance().exit();

					}
				})
				.setNegativeButton("取消", new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {
					}
				}).create();
		// 显示提示框
		dialog.show();
	}

}
